from django.db import models


# Create your models here.
class Equipment(models.Model):
    # 定义设备的3中状态
    STATUS_CHOICES = (
        (0, 'free'),
        (1, 'busy'),
        (2, 'forbidden')
    )
    # 设备id
    e_id = models.CharField(verbose_name='设备id', max_length=50, unique=True)
    # 设备名称
    e_title = models.CharField(verbose_name='Title', max_length=50, default='')
    e_location = models.CharField(verbose_name='Location', max_length=100, default='')
    # 设备ip
    e_iDrac_ip = models.CharField(verbose_name='iDrac_ip', max_length=50, default='')
    # 设备状态，0表示可用，1表示被占用，2表示禁用
    e_status = models.IntegerField(verbose_name='Status', choices=STATUS_CHOICES, default=0)
    e_tag = models.CharField(verbose_name='Tag', max_length=50, default='')
    # 设备配置，以字符串形式保存一个json文件
    e_configuration = models.TextField(verbose_name='Configuration', default='')
    # 设备组织
    e_servergroup = models.CharField(verbose_name='ServerGroup', max_length=50, default='')
    # 设备物理地址
    e_geolocation = models.CharField(verbose_name='GeoLocation', max_length=100, default='')
    # 设备的cluster
    e_cluster = models.CharField(verbose_name='Cluster', max_length=100, default='')

    class Meta:
        db_table = 'hwb_equipment'

    def __self__(self):
        return self.e_title
